package com.zkingsoft.actions.admin;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zkingsoft.actions.common.BaseController;
import com.zkingsoft.model.PaginationVO;
import com.zkingsoft.model.Webinfo;
import com.zkingsoft.pojo.AjaxResult;
import com.zkingsoft.services.WebinfoService;

/**
 * @description 网站信息管理
 * @author Matrix-J E-mail:<935090232@qq.com>
 * @date 2016-04-21
 */
@Controller
@RequestMapping(value = "/admin/webinfo")
public class WebInfoController extends BaseController {

	@Resource
	private WebinfoService currentService;

	@RequestMapping(value = "/showList")
	public @ResponseBody AjaxResult showList(HttpServletRequest request, Webinfo webinfo, PaginationVO pageVo) {
		webinfo.setCompanyId(getMe(request).getCompanyId());
		return showList(currentService, webinfo, pageVo);
	}

	@RequestMapping(value = "/addOrModify")
	public @ResponseBody AjaxResult addOrModify(Webinfo webinfo) {
		if (webinfo.getId() != null) {
			return modify(currentService, webinfo, "信息");
		} else {
			webinfo.setCompanyId(getMe().getCompanyId());
			return add(currentService, webinfo, "信息");
		}
	}

	@RequestMapping(value = "/del")
	public @ResponseBody AjaxResult del(String keys) {
		return remove(currentService, keys);
	}

	@RequestMapping(value = "/editForm")
	public String editForm(Long id, HttpServletRequest request) {
		Webinfo webinfo;
		if (id != null) {
			webinfo = currentService.findById(id);
			request.setAttribute("obj", webinfo);
		}
		return "admin/webinform-form";
	}

	@RequestMapping(value = "/all")
	public @ResponseBody AjaxResult all(HttpServletRequest request) {
		Webinfo webinfo = new Webinfo();
		webinfo.setCompanyId(getMe(request).getCompanyId());
		return findByModel(currentService, webinfo);
	}
}